home *** CD-ROM | disk | FTP | other *** search
- /////////////////////////////////////////////////////////////////////////////// //
- // $Id: StatInfo.cxx,v 1.1 1994/02/18 19:53:40 bmott Exp $
- /////////////////////////////////////////////////////////////////////////////// //
- // StatInfo.cxx
- //
- // This class is used by BasicCPU (and derived classes) to manage a list of
- // of statistics objects.
- //
- //
- // BSVC "A Microprocessor Simulation Framework"
- // Copyright (c) 1993
- // By: Bradford W. Mott
- // December 5,1993
- //
- ///////////////////////////////////////////////////////////////////////////////
- // $Log: StatInfo.cxx,v $
- // Revision 1.1 1994/02/18 19:53:40 bmott
- // Initial revision
- //
- ///////////////////////////////////////////////////////////////////////////////
-
- #include <string.h>
- #include "StatInfo.hxx"
-
- ///////////////////////////////////////////////////////////////////////////////
- // One of the StatisticInformation constructor
- ///////////////////////////////////////////////////////////////////////////////
- StatisticInformation::StatisticInformation(const char* s)
- {
- statistic=new char[strlen(s)+1];
- strcpy(statistic,s);
- }
-
- ///////////////////////////////////////////////////////////////////////////////
- // The other StatisticInformation constructor
- ///////////////////////////////////////////////////////////////////////////////
- StatisticInformation::StatisticInformation()
- {
- statistic=(void*)0;
- }
-
- ///////////////////////////////////////////////////////////////////////////////
- // The StatisticInformation destructor
- ///////////////////////////////////////////////////////////////////////////////
- StatisticInformation::~StatisticInformation()
- {
- delete[] statistic;
- }
-
- ///////////////////////////////////////////////////////////////////////////////
- // Set the statistic, and description
- ///////////////////////////////////////////////////////////////////////////////
- void StatisticInformation::Set(const char* s)
- {
- delete[] statistic;
-
- statistic=new char[strlen(s)+1];
- strcpy(statistic,s);
- }
-
-
- ///////////////////////////////////////////////////////////////////////////////
- // The StatisticalInformationList constructor
- ///////////////////////////////////////////////////////////////////////////////
- StatisticalInformationList::StatisticalInformationList(BasicCPU* cpu)
- {
- head=tail=(void*)0;
- number_of_elements=0;
- cpu->BuildStatisticalInformationList(this);
- }
-
- ///////////////////////////////////////////////////////////////////////////////
- // The class destructor
- ///////////////////////////////////////////////////////////////////////////////
- StatisticalInformationList::~StatisticalInformationList()
- {
- StatisticInformationNode* p;
- StatisticInformationNode* q;
-
- // Delete the list of nodes
- p=head;
- while (p!=(void*)0)
- {
- q=p->next;
- delete p;
- p=q;
- }
- }
-
- ///////////////////////////////////////////////////////////////////////////////
- // Append a new node to the list
- ///////////////////////////////////////////////////////////////////////////////
- void StatisticalInformationList::Append(const char* statistic)
- {
- StatisticInformationNode* n;
- n = new StatisticInformationNode(statistic);
-
- if(tail==(void*)0)
- {
- head = tail = n;
- }
- else
- {
- tail->next = n;
- tail = n;
- }
-
- ++number_of_elements;
- }
-
- ///////////////////////////////////////////////////////////////////////////////
- // Return a specific element from the list
- ///////////////////////////////////////////////////////////////////////////////
- int StatisticalInformationList::Element(int index,StatisticInformation& info)
- {
- StatisticInformationNode* p;
- int t;
-
- for(t=0,p=head;(t<index) && (p!=(void*)0);++t,p=p->next);
-
- if(t==index)
- {
- info.Set(p->Statistic());
- return(1);
- }
- else
- {
- return(0);
- }
- }
-
-